<?php
namespace app\admin\controller;

\think\Loader::import('controller/Controller', \think\Config::get('traits_path') , EXT);

use app\admin\Controller;


class QueueHistory extends Controller
{
    use \app\admin\traits\controller\Controller;
    // 方法黑名单
    protected static $blacklist = [];

    protected function filter(&$map)
    {
        if ($this->request->param("branchid")) {

            $branchid = model('branch_list')->where(['name'=>['like', '%'.$map['branchid'].'%']])->value('id');

            $map['branchid'] = $branchid;
        }
        if ($this->request->param("bisid")) {

            $bisid = model('businessList')->where(['name'=>['like', '%'.$map['bisid'].'%']])->value('id');
            $map['bisid'] = $bisid;

        }
        if ($this->request->param("type")) {


            if(strpos("预约取号",$this->request->param("type")) !== false){

                $map['type'] = 1;
            }
            else if(strpos("在线取号",$this->request->param("type")) !== false){

                $map['type'] = 2;
            } else if(strpos("线下取号",$this->request->param("type")) !== false){

                $map['type'] = 3;
            }
        }


        if ($this->request->param("truename")) {
            $map['truename'] = ["like", "%" . $this->request->param("truename") . "%"];
        }
//        if ($this->request->param("mobile")) {
//            $map['mobile'] = ["like", "%" . $this->request->param("mobile") . "%"];
//        }

        if ($this->request->param("queue_time_start") && $this->request->param("queue_time_end")) {

            $queue_time_start = strtotime($this->request->param("queue_time_start"));
            $queue_time_end = strtotime($this->request->param("queue_time_end"));

            $map['queue_time'] = [['>',$queue_time_start],['<',$queue_time_end],'AND'];

        }

        if ($this->request->param("queue_time_start") && !$this->request->param("queue_time_end")) {

            $queue_time_start = strtotime($this->request->param("queue_time_start"));


            $map['queue_time'] = ['>',$queue_time_start];

        }

        if (!$this->request->param("queue_time_start") && $this->request->param("queue_time_end")) {


            $queue_time_end = strtotime($this->request->param("queue_time_end"));

            $map['queue_time'] = ['<',$queue_time_end];

        }

    }
}
